package com.meixiang.activity.account;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.View;

import com.google.gson.Gson;
import com.lzy.okhttputils.model.HttpParams;
import com.meixiang.R;
import com.meixiang.entity.collect.CollectEntity;
import com.meixiang.fragment.collect.AllCollectFragment;
import com.meixiang.global.Config;
import com.meixiang.http.HttpCallBack;
import com.meixiang.http.HttpUtils;
import com.meixiang.main.BaseViewPagerActivity;

import org.json.JSONObject;

/**
 * 收藏
 * xiejingwen
 */
public class CollectActivity extends BaseViewPagerActivity {
    private CollectEntity mCollectEntity;

    @Override
    protected String[] getTitles() {

        return new String[]{"全部","商品","服务"};
    }

    @Override
    protected Fragment[] getFragments() {
        setViewpagerSlide(false);
        getData();
        return new Fragment[]{AllCollectFragment.getInstance("0"),AllCollectFragment.getInstance("1"),AllCollectFragment.getInstance("2")};
    }

    @Override
    protected int ColorStyle() {
        return R.color.financial_red_color ;
    }

    @Override
    protected void setTitle() {
        setTitle("收藏");
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    public void getData(){
        HttpParams params = new HttpParams();
        params.put("favType","0");
        params.put("pageSize", "10");
        params.put("pageNo", "1");
        HttpUtils.post(Config.COLLECT_LIST, params, new HttpCallBack(this) {
            @Override
            public void onSucceed(JSONObject result, String code, String message) {
                mCollectEntity = new Gson().fromJson(result.toString(), CollectEntity.class);
                setTabText(0, "全部(" + mCollectEntity.getCountTotal() + ")");
                setTabText(1, "商品(" + mCollectEntity.getGoodsTotalRows() + ")");
                setTabText(2, "服务(" + mCollectEntity.getServeTotalRows() + ")");
            }

            @Override
            public void onError(String code, String message) {

            }
        });
    }

    @Override
    public void onClick(View v) {

    }
}
